/*
 * @Date: 2025-02-02 20:38:13
 * @LastEditors: 吴世扬 18368095041@163.com
 * @LastEditTime: 2025-02-13 18:10:46
 * @FilePath: /vue3-admin/src/api/login.ts
 */

import { request } from '@/utils';

export class LoginParam {
    username = '';
    password = '';
    captcha = '';
}

export const login = (data: LoginParam) => {
    return request<HttpResult<string>>({
        url: '/admin/api/v1/login/login',
        method: 'post',
        data
    }).then((res) => {
        return res.data;
    });
};

export const logout = () => {
    return request<HttpResult<string>>({
        url: '/admin/api/login/logout',
        method: 'post'
    }).then((res) => {
        return res.data;
    });
};

export const generateCaptchaUrl = () => {
    return (
        import.meta.env.VITE_APP_BASE_API +
        '/admin/api/v1/login/captcha?t=' +
        new Date().getTime().toString()
    );
};
